home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / tchrt3.zip / DEMOV3.C < prev    next >
Text File  |  1990-07-23  |  4KB  |  98 lines

  1. /*---------------------------------------------------------------------------
  2.  |  Program DEMOV3.C                                                        |
  3.  |                                                                          |
  4.  |  This program demonstrates some of the capabilities of TCHRT V3          |
  5.  |                                                                          |
  6.  |  (c) 1989 Ryle Design, P.O. Box 22, Mt. Pleasant, Michigan 48804         |
  7.  |                                                                          |
  8.  |  V3.00  Turbo C Shareware Evaluation Version                             |
  9.  ---------------------------------------------------------------------------*/
  10.  
  11. #include <stdio.h>
  12. #include <conio.h>
  13. #include <math.h>
  14. #include <process.h>
  15.  
  16. #include "pchrt.h"
  17.  
  18.  
  19. void sin_funct(void)
  20. /*---------------------------------------------------------------------------
  21.  |  A simple function to time.  PCHRT will tell us how many times this      |
  22.  |  function was called and how much time we spent here.                    |
  23.  |                                                                          |
  24.  |  Globals referenced: none                                                |
  25.  |                                                                          |
  26.  |  Arguments: void                                                         |
  27.  |                                                                          |
  28.  |  Returns: void                                                           |
  29.  ---------------------------------------------------------------------------*/
  30. {
  31.     double  alpha;
  32.  
  33.     t_entry(4);                                             /* start timer 4 */
  34.  
  35.     alpha = sin(2.2734593);                                 /* do something */
  36.  
  37.     t_exit(4);                                              /* stop timer 4 */
  38.  
  39. } /* sin_funct */
  40.  
  41.  
  42. void main(void)
  43. {
  44.     char            tstring[25];
  45.     long unsigned   hits, elapsed;
  46.     int             indx;
  47.  
  48.     t_request(5);                                           /* ask for 5 timers */
  49.     if (t_start() != TRUE)                                  /* init TCHRT first thing */
  50.     {
  51.         printf("Insufficient heap for TCHRT operation.\n");
  52.         exit(0);
  53.     }
  54.  
  55.     t_entry(0);                                             /* we use timer 0 to time whole run */
  56.  
  57.     printf("TCHRT V3 Demonstration\n\n");
  58.  
  59.     printf("Press any key >> ");
  60.  
  61.     t_entry(2);                                             /* time getch() with timer 2 */
  62.     getch();
  63.     t_exit(2);
  64.  
  65.     t_ask_timer(2,&hits,&elapsed);                          /* get timer 2 results */
  66.  
  67.     printf("\nResponse time was %s\n",t_cvt_time(elapsed,tstring) );
  68.  
  69.     printf("\nCalling sin function with embedded timer 100 times ... ");
  70.     for (indx=0; indx<100; indx++) sin_funct();
  71.     printf("complete\n\n");
  72.  
  73.     printf("Press any key to generate timer reports >> ");
  74.     getche();
  75.     printf("\n");
  76.  
  77.     t_exit(0);                                              /* stop timer timing total run time */
  78.  
  79.     t_set_report(NONZERO);                                  /* specify report type */
  80.     t_rname("NONZERO report type");                         /* report title        */
  81.     t_name(0,"Total run time");                             /* give each timer a name */
  82.     t_name(2,"getch() response");
  83.     t_name(4,"sin() function");
  84.     t_report(0);                                            /* do report - (0) goes to CRT */
  85.  
  86.     t_set_report(HIGHWATER);                                /* request different report type */
  87.     t_rname("HIGHWATER report type");                       /* new name */
  88.     t_report(0);                                            /* do it */
  89.  
  90.     t_stop();                                               /* shut down TCHRT and free heap */
  91.  
  92.     printf("TCHRT V3 Demo complete\n");                     /* all done ... */
  93.  
  94. } /* main */
  95.  
  96.  
  97.  
  98.